#ifndef _PACKET_PARSER_EX_H_
#define _PACKET_PARSER_EX_H_

#include "Define.h"
#include "IPacketParser.h"
#include "EndianOp.h"

class CPacketParserEx : public SGLib::IPacketParser
{
public:

    struct tagHeader
    {
        s32 len;
        u32 msgid;
    };

    s32 GetHeadLen()
    {
        return sizeof(struct tagHeader);
    }
    s32 GetPacketLen(const byte *data)
    {
        tagHeader *header = (tagHeader*)data;
        return _NTOH32(header->len);
    }
    void FillHeader(byte *data, s32 len, u32 msgid)
    {
        tagHeader *header = (tagHeader*)data;
        header->len = _HTON32(len);
        header->msgid = _HTON32(msgid);
    }
    u32 GetMsgId(const byte *data)
    {
        tagHeader *header = (tagHeader*)data;
        return _NTOH32(header->msgid);
    }
};

#endif

